from typing import *


# Definition for Employee.
class Employee:
    def __init__(self, id: int, importance: int, subordinates: List[int]):
        self.id = id
        self.importance = importance
        self.subordinates = subordinates


class Solution:
    def getImportance(self, employees: List["Employee"], id: int) -> int:
        h = {}
        for empl in employees:
            h[empl.id] = empl

        def f(id):
            empl = h[id]
            ans = empl.importance
            for s in empl.subordinates:
                ans += f(s)
            return ans

        return f(id)
